package  
{
	/**
   * ...
   * @author Ivan
   */
  public class Player 
  {
    
    public function Player() 
    {
      
    }
    
    public var color:uint;
    public var gold:int;
    public var name:String;
    
    public function get human():Boolean { return !_controller; }
    
    public function get controller():AIController { return _controller; }
    public function set controller(val:AIController):void
    {
      _controller = val;
      _controller.player = this;
    }
    
    public function update():void
    {
      var myTowns:Vector.<Town> = GameBoard.towns.filter(friendlyTownsFilter, this);
      gold += myTowns.length;
      
      if (infoPanel)
        infoPanel.update();
    }
    
    private function friendlyTownsFilter(t:Town, index:int, vector:Vector.<Town>):Boolean { return t.owner === this; }
    
    private var _controller:AIController;
    public var infoPanel:PlayerInfoPanel;
    
  }

}